export function useMutationObserver(vNodes: HTMLElement | HTMLElement[], callback: MutationCallback) {
  const MutationObserver = window.MutationObserver || (window as any).WebKitMutationObserver || (window as any).MozMutationObserver
  if (vNodes instanceof HTMLElement) vNodes = [vNodes]
  const observers = []
  for (const vNode of vNodes) {
    const config = { attributes: true, childList: true, subtree: true }

    const observer = new MutationObserver(callback)

    observer.observe(vNode, config)
    observers.push(observer)
  }
  return observers
}

export function useResizeObserver(vNodes: HTMLElement | HTMLElement[], callback: ResizeObserverCallback) {
  if (vNodes instanceof HTMLElement) vNodes = [vNodes]
  const observers = []
  for (const vNode of vNodes) {
    const observer = new ResizeObserver(callback)
    observer.observe(vNode)
    observers.push(observer)
  }
  return observers
}
